package com.lvtongka.app.common

import android.os.CountDownTimer
import android.widget.TextView
import com.lvtongka.app.common.listener.CountDownCallback

class DialogCountDownTimer(
    var timerTv: TextView,
    millisInFuture: Long,
    countDownInterval: Long,
    val callback: CountDownCallback
) :
    CountDownTimer(millisInFuture, countDownInterval) {

    override fun onTick(millisUntilFinished: Long) {
        timerTv?.let {
            var down = millisUntilFinished / 1000
            timerTv.text = "去登录（${down}s）"
        }
    }

    override fun onFinish() {
        timerTv?.let {
            //重新设置文字
            timerTv.text = "去登录"
            callback.onFinish()
        }
    }
}